package com.daoeping.dao;

import java.util.List;

import org.json.JSONArray;

import com.daoeping.domain.Cop_companyinfo;
import com.daoeping.domain.JsonData;
import com.daoeping.util.ConverntJsonData;

public class CompanyinfoDao  extends AllDaoSupport {
	@SuppressWarnings("unchecked")
	public JsonData findCop_companyinfos(Cop_companyinfo cop_companyinfo ) {
		try {
			StringBuilder sb = new StringBuilder();
			sb.append("select cop.name , cop.id , cop.description from Cop_companyinfo cop  ");
			if(cop_companyinfo!=null&&cop_companyinfo.getId()!=0){
				sb.append(" where cop.id = '"+cop_companyinfo.getId()+"'");
			}else{
				sb.append("");
			}
			List<Object[]> resultlist =  (List<Object[]>)this.selectDataByHQL(sb.toString());
			JSONArray json = new ConverntJsonData().getJsonData(resultlist);
			System.out.println(json);
			JsonData jsonData = new JsonData();
			jsonData.setJsonData(json.toString());
			return jsonData;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	

}
